package com.ophiux.cs.domain.chat.model.entity;

import com.ophiux.compoments.TableEnum;
import com.ophiux.cs.domain.core.Entity;
import com.ophiux.cs.domain.core.TbableUniqueIDFactory;
import com.ophiux.utils.common.DateUtil;

/**
 * 消息类型表
 * @author chenh
 *
 */
public class CSChatMessageInfo extends Entity{

	private final static String STATE_VALID = "1";	//有效
	private final static String STATE_INVALID = "0";	//无效
	private final static String STATE_UNDO = "2";	//撤回
	
	private String MSG_ID;	//消息内容ID  和消息内容表关联
	
	private String FROM_USER;	//消息来源
	
	private String MSG_TYPE;	//	消息类型	VARCHAR2(32)	不可空	1：图文
	
	private String CONTENT;	//消息内容   不可空   200字内
	
	private String STATE;	//消息状态   1：有效   2：撤回    0：无效(暂未使用)
	
	private String CREATE_TIME;	//创建时间
	
	private String RECENT_TIME;	//最新时间
	
	private String DIALOG_ID;	//对话ID  可空
	
	private String  SEND_SCOPE;	// Y	String	发送范围，1：私发   2：群发
	
	public CSChatMessageInfo(String dIALOG_ID , String fROM_USER, 
			String mSG_TYPE, String cONTENT , String sEND_SCOPE) {
		super();
		MSG_ID = TbableUniqueIDFactory.getInstance()
				.createUniqueID(TableEnum.TABLE_SQE_CS_ChAT_MESSAGE_INFO.toString());
		this.DIALOG_ID = dIALOG_ID;
		FROM_USER = fROM_USER;
		MSG_TYPE = mSG_TYPE;
		CONTENT = cONTENT;
		this.CREATE_TIME = DateUtil.getCurDateStr();	//取当前时间
		this.STATE = STATE_VALID;	//默认有效
		this.SEND_SCOPE = sEND_SCOPE;
	}

	public String getSEND_SCOPE() {
		return SEND_SCOPE;
	}

	public void setSEND_SCOPE(String sEND_SCOPE) {
		SEND_SCOPE = sEND_SCOPE;
	}

	public String getMSG_ID() {
		return MSG_ID;
	}

	public void setMSG_ID(String mSG_ID) {
		MSG_ID = mSG_ID;
	}

	public String getMSG_TYPE() {
		return MSG_TYPE;
	}

	public void setMSG_TYPE(String mSG_TYPE) {
		MSG_TYPE = mSG_TYPE;
	}

	public String getCONTENT() {
		return CONTENT;
	}

	public void setCONTENT(String cONTENT) {
		CONTENT = cONTENT;
	}

	public String getSTATE() {
		return STATE;
	}

	public void setSTATE(String sTATE) {
		STATE = sTATE;
	}

	public String getDIALOG_ID() {
		return DIALOG_ID;
	}

	public void setDIALOG_ID(String dIALOG_ID) {
		DIALOG_ID = dIALOG_ID;
	}

	public String getCREATE_TIME() {
		return CREATE_TIME;
	}

	public void setCREATE_TIME(String cREATE_TIME) {
		CREATE_TIME = cREATE_TIME;
	}

	public String getRECENT_TIME() {
		return RECENT_TIME;
	}

	public void setRECENT_TIME(String rECENT_TIME) {
		RECENT_TIME = rECENT_TIME;
	}

	public String getFROM_USER() {
		return FROM_USER;
	}

	public void setFROM_USER(String fROM_USER) {
		FROM_USER = fROM_USER;
	}
	
	/**
	 * 消息是否有效
	 * @return
	 */
	public boolean isValid() {
		return this.getSTATE().equals(STATE_VALID) ? true : false;
	}
	
	/**
	 * 撤回
	 */
	public void undo() {
		this.setSTATE(STATE_UNDO);
		this.setRECENT_TIME(DateUtil.getCurDateStr());
	}
	
}
